package cn.liuxiany.alibaba.provider.dubbo;

import cn.liuxiany.alibaba.provider.api.MultService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;

/**
 * @author liuxiany
 * @date 2023/10/13
 */
@Slf4j
@DubboService
public class MultServiceImpl implements MultService {

    private static final String X_REQUEST_IP = "X-Request-Id";// nginx需要配置

    @Override
    public String hello2(String name) {
        String requestId = RpcContext.getContext().getAttachment(X_REQUEST_IP);
        log.info("requestId is {}", requestId);

        // 向consumer写回参数
        RpcContext.getServerContext().setAttachment("hello2", "hello world haha22222");
        return "链路调用啊：" + name;
    }
}
